package net.yihang.helper;

public class Tuple2 {
    private String name;
    private Double sum;
    private int count=1;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Tuple2 add(Tuple2 b) {
        count += b.count;
        sum += b.sum;
        return this;
    }

    public Double avg() {
        return sum / count;
    }

    public Tuple2(String name, Double sum) {
        this.name = name;
        this.sum = sum;
    }

    @Override
    public String toString() {
        return "Tuple2{" +
                "name='" + name + '\'' +
                ", sum=" + sum +
                ", count=" + count +
                ", avg=" + avg() +
                '}';
    }
}
